﻿using FileServer.Core;
using FileServer.Core.Configuration;
using FileServer.Core.Server;

namespace Microsoft.Extensions.Hosting;

public static class ServiceCollectionExtensions
{
    public static IServiceCollection AddFileServerServices(this IServiceCollection services,
        IConfiguration configuration, IHostEnvironment hostEnvironment)
    {
        services.AddOptions<FileServerOption>()
            .Bind(configuration.GetSection(FileServerOption.FileServerSetting));
        services.AddSingleton<IFileServerListener, DotNettyFileServerListener>();
        services.AddHostedService<InitFileServerHostedService>();
        return services;
    }
}